﻿using B.S.Procurement.Domain;
using B.S.Procurement.Error;
using B.S.Procurement.Read.Api.Application.Command.ClientCommand;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Procurement.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ClientController : ControllerBase
    {
        private readonly IMediator mediator;

        public ClientController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 查询客户信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiPaging<List<Client>>> QueryClient([FromQuery] QueryClientCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 反填客户数据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<Client>>> ShowClient([FromQuery] ShowClientCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 没条件查询客户
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<Client>>> GetClient([FromQuery] GetClientCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
